package biopepa;



public class NewLocation {
	
	public String locationName ;
	public double locationSize ;
	public double locationStepSize ;
	public String locationType ;
	public String stepSizeVariableC;
	public String stepSizeVariableD;
	public boolean isFirstLocation;
	
	public NewLocation(BiopepaModel model) {
		
		locationName = "main";
		locationSize=1;
		locationStepSize = 1;
		locationType = "-";
		if(model.hasLocations == true){
			stepSizeVariableC = "hC." + locationName;
			stepSizeVariableD = "hD." + locationName;	
		}
		else{
			stepSizeVariableC = "h.C";
			stepSizeVariableD = "h.D";	
		}
		isFirstLocation = false;
	}
	
	public NewLocation(String name , BiopepaModel model) {
		
		this.locationSize=0;
		this.locationName = name;
		this.locationStepSize = 1;
		this.locationType = "compartment";
		
		if(model.hasLocations == true){
			stepSizeVariableC = "h.C." + locationName;
			stepSizeVariableD = "h.D." + locationName;	
		}
		else{
			stepSizeVariableC = "h.C";
			stepSizeVariableD = "h.D";	
		}
		
		isFirstLocation = false;
	}
	
	public void setLocationSize(String size) {
		locationSize = Double.parseDouble(size);
	}
	
	public void setLocationStepSize(BiopepaModel model , String stepSize) {
		locationStepSize = Double.parseDouble(stepSize );
		NewParameter paramOne = model.parameterObjects.get(stepSizeVariableC);
		NewParameter paramTwo = model.parameterObjects.get(stepSizeVariableD);
		paramOne.parameterExpression = String.valueOf(locationStepSize);
		paramTwo.parameterExpression = String.valueOf(locationStepSize);
		paramOne.isStepSize = true;
		paramTwo.isStepSize = true;
	}
	
	public void setLocationStepSize(BiopepaModel model , double stepSize) {
		locationStepSize = stepSize;
		NewParameter paramOne = model.parameterObjects.get(stepSizeVariableC);
		NewParameter paramTwo = model.parameterObjects.get(stepSizeVariableD);
		paramOne.parameterExpression = String.valueOf(locationStepSize);
		paramTwo.parameterExpression = String.valueOf(locationStepSize);
		paramOne.isStepSize = true;
		paramTwo.isStepSize = true;
	}
	
	public void setLocationType(String type) {
		locationType = type;	
	}
	
	public String toString() {
		return locationName;
	}
	
	

}
